<?php
/**
 * Implementation of hook_insert. 
 * Responds to node insertion.
 */
function race_insert($node) {
  db_insert('race')
  ->fields(array(
	  'vid' => $node->vid,
    'nid' => $node->nid,
    'config' => $node->config,
    'signup' => $node->signup,
    'assignment' => $node->assignment,
    'state' => $node->state)
  )->execute();
}

/**
 * Implementation of hook_update(). 
 * Responds to node updating.
 */
function race_update($node) {
  db_update('race')
  ->fields(array(
      'config' => $node->config,
      'signup' => $node->signup,
      'assignment' => $node->assignment,
      'state' =>  $node->state,
  ))
  ->condition('nid', $node->nid, '=')
  ->execute();
}

/**
 * Implementation of hook_load().
 * Load node-type-specific information.
 */
function race_load($nodes) {
  $result = db_query('SELECT config, signup, assignment, state, nid FROM {race} WHERE nid IN (:nids)', array(':nids' => array_keys($nodes)));
  foreach ($result as $record) {
    $nodes[$record->nid]->config = $record->config;
    $nodes[$record->nid]->signup = $record->signup;
    $nodes[$record->nid]->assignment = $record->assignment;
    $nodes[$record->nid]->state = $record->state;
  };
}
